import { defineStore } from "pinia";
import { reqAllFilm, reqFilmByType } from "@/api/moive";
import { FilmResponseData } from "@/api/moive/type.ts";

const useFilmStore = defineStore("Film", {
  state: (): any => {
    return {
      searList: []
    };
  },
  actions: {
    async searchFilm(data: any) {
      const res: FilmResponseData = await reqAllFilm(data);
      console.log(res);
      if (res.code === 1) {
        this.searList = res.data.records;
      }
    },
    async searchFilmByType(data: any) {
      const res: FilmResponseData = await reqFilmByType(data);
      console.log(res);
      if (res.code === 1) {
        this.searList = res.data.records;
      }
    }
  },
  getters: {}
});

export default useFilmStore;